from selenium.webdriver.common.by import By
from common.Utils import BlogDriver

class BlogEdit:
    driver=""
    url=""
    def __init__(self):
        self.driver=BlogDriver.driver
        #设置 隐式等待
        self.driver.implicitly_wait(5)
        self.url="http://8.137.19.140:9090/blog_update.html?blogId=43914"
        self.driver.get(self.url)

    def EditTest(self):
        # 检查博客编辑页的 “更新文章” 按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#submit")
        #检查博客编辑页 标题输入框 是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#title")
        #检查博客编辑页 菜单栏 是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#editor > div.editormd-toolbar > div")
        #博客系统中编辑区域是第三方插件，不能通过元素定位
        #博客系统中编辑区域是第三方插件，不能通过元素定位，所以只测试能否 编辑修改标题 发布文章
        self.driver.find_element(By.CSS_SELECTOR,"#title").clear()
        self.driver.find_element(By.CSS_SELECTOR,"#title").send_keys("自动化测试")
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        text=self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div:nth-child(1) > div.title").text
        assert text=="自动化测试"







